<template>
  <div class="contest">
    <div class="wrapper" ref="wrapper">
      <ul class="content" ref="content">
        <li v-for="obj in reList" :key="obj.index">
          <div class="cover">
            <van-image :src="obj.picUrl" radius="1rem" class="imgim" />
            <span>{{ obj.playCount | numFilter(2) }}万</span>
          </div>
          <span>{{ obj.name }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { recommendMusicAPI } from "@/api";
import BScroll from "better-scroll";

export default {
  data() {
    return {
      reList: [],
    };
  },
  async created() {
    const res = await recommendMusicAPI({
      limit: 12,
    });
    console.log(res);
    this.reList = res.data.result;
    this.betterScrollHorizontal();
  },

  methods: {
    betterScrollHorizontal() {
      this.$nextTick(() => {
        this.scroll = new BScroll(this.$refs.wrapper, {
          click: true,
          startX: 0,
          scrollX: true,
          scrollY: false,
        });
      });
    },
  },
};
</script>

<style  scoped>
.title_sub {
  float: left;
  font-size: larger;
  margin: 8px 8px;
}
.cover {
  height: 150px;
  width: 150px;
  position: relative;
}
.imgim {
  height: 150px;
  width: 150px;
}
.cover > span {
  position: absolute;
  right: 0.2rem;
  bottom: 8rem;
  background-color: rgba(167, 166, 166, 0.5);
  color: white;
  border-radius: 1rem;
  display: inline-block;
  margin: 4rem 4px;
}
.wrapper {
  width: 100%;
  overflow: hidden;
}
ul.content {
  width: calc(12 * 10rem);
}
ul.content li {
  display: inline-block;
  width: 5rem;
  vertical-align: top;
}
ul.content li * {
  margin: 0.1rem;
  margin-bottom: 5px;
}
ul.content li > span {
  font-size: 0.4rem;
  color: #54493b;
}
.contest-sub {
  margin: 20px 20px;
}
.contest {
  /* background: #c4c3c3; */
  height: 200px;
  /* background-color: aliceblue; */
  border-bottom-right-radius: 5px;
  border-bottom-left-radius: 5px;
  margin-bottom: 30px;
  box-shadow: 0px 2px 2px #c4c3c3;
}
</style>
